/**
 * 会诊管理
 */
import request, { IResposeItem } from "@/configs/request"
import { iteratee } from "lodash"
import { IPages } from "./common.d"


export interface IConsultListParmas<T = number> {
  current: number,
  size: number,
  patientName?: string,
  status?: T,
  topic?: string
}




type IResposeWithNull<R> = {
  [K in keyof R]?: R[K] | null | undefined
}

interface IResposeExNull<R> {
  [k: string]: R | null | undefined
}



export interface Irecords extends Record<string, any> {
  id: number | null | undefined,
  topic: string | null | undefined,//	会诊主题
  goal: string | null | undefined,// 会诊目标
  patientName: string | null | undefined,//	患者名称
  patientSex: number | null | undefined,
  patientSexRes: string | null | undefined,// 患者性别描述
  patientAge: number | null | undefined,
  patientType: number | null | undefined,//
  patientTypeRes: string | null | undefined,// 患者类型
  diagnosis: string | null | undefined,//	主要诊断
  status: number | null | undefined,
  statusRes: string | null | undefined,// 会诊状态描述
  groupName: string | null | undefined,//	会诊组名
  contactName: string | null | undefined,// contactName
  applierName: string | null | undefined,//	申请人
  startTime: string | null | undefined,//	开始时间
  createBy: number | null | undefined,//	申请人ID
  leaderId: number | null | undefined,//	组长ID
  leaderName: string | null | undefined,//	组长名称
  attendStatus: number | null | undefined,
  attendStatusRes: string | null | undefined,//	出席状态描述
  remark: string | null | undefined,//	出席状态描述
}

export interface IConsultListData extends IPages {
  records: Array<Irecords>

}

export interface IRespose extends IResposeItem<IConsultListData> {
  other: string
}

/**
 * 分页查询所有会诊列表
 * @param parmas 
 * @returns 
 */
// , { headers: { Authorization: "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJkZXZpY2VUeXBlIjoyLCJob3NwaXRhbFV1aWQiOiJiMjUxNGRhN2FlZDIxMWViOWM5MjAwMGMyOWZmNjFmYiIsInBob25lIjoiMTMyNDczMjg0NzUiLCJ1c2VySWQiOjEwLCJ1dWlkIjoiYzllZDZiZGU4Y2VjNDgxZTkwZWI2MTMyMWNhYmNlMDUifQ.efQUF1tt12kFHhb0Z39NJFn7jC_SHJmJcVGX65WbfdE" } }
export const consultList = async (parmas: IConsultListParmas): Promise<IResposeItem<IConsultListData>> => {
  return request.post("/cr/crConsult/pageList", parmas)
}

/**
 * 
 * @param parmas 测试
 * @returns 
 */
export const consultGroupUser = async (parmas: any): Promise<IResposeItem<any>> => {
  return request.post("/cr/crConsultGroup/pageList", parmas)
}


interface IOverview {
  totalCount: number;
  toBeReviewedCount: number;
  endedCount: number;
  finishedCount: number;
}

/**
 * 会诊概览
 * @returns 
 */

export const overview = async (): Promise<IResposeItem<IOverview>> => {
  return request.get("/cr/crConsult/overview")
}

export interface IRemarkParmas {
  consultId: number;
  remark: string;
}

/**
 * 修改会诊备注
 * @param consultId 
 * @param remark 
 * @returns 
 */
export const updateRemark = async (consultId: number, remark: string): Promise<IResposeItem<any>> => {
  return request.post("/cr/crConsult/updateRemark", { consultId, remark })
}




